import request from "@/utils/request";
import {PATH_SYS_DNF} from "@/utils/constant";
import {UpWeaponResultVo, UserWeapon} from "@/api/sys/dnf/user-weapon/types";

const baseUrl = PATH_SYS_DNF + '/user-weapon/'

/**
 * 查询我的武器列表 - 带分页
 * @param data
 */
export function getUserWeaponListApi(data: PageQuery<UserWeapon>): PromisePageListType<UserWeapon> {
    return request.post(baseUrl + 'list', data)
}

/**
 * 通过我的武器id获取我的武器信息
 * @param id
 */
export function getUserWeaponByIdApi(id: number): Promise<UserWeapon> {
    return request.get(baseUrl + id)
}

/**
 * 修改我的武器
 * @param id
 * @param data
 */
export function editUserWeaponApi(id: number, data: UserWeapon): Promise<any> {
    return request.patch(baseUrl + id, data)

}

/**
 * 添加我的武器
 * @param data
 */
export function addUserWeaponApi(data: UserWeapon): Promise<any> {
    return request.post(baseUrl, data)
}

/**
 * 删除我的武器
 * @param id
 */
export function deleteUserWeaponApi(id: number): Promise<any> {
    return request.delete(baseUrl + id)
}

/**
 * 购买武器
 * @param weaponId
 */
export function buyUserWeaponApi(weaponId: number): Promise<any> {
    return request.post(baseUrl + 'buy/' + weaponId)
}

/**
 * 增幅武器
 * @param userWeaponId
 * @param upType
 */
export function upUserWeaponApi(userWeaponId: number,upType:number): Promise<UpWeaponResultVo> {
    return request.post(baseUrl + 'weapon-up/' + userWeaponId,{upType})
}